package abel.wlmr.model.type;

import java.util.HashMap;
import java.util.Map;

public enum PortType {
    PortAlter(1),
    PortRs485_1(2),
    PortRs485_2(3),
    PortRs485_3(4),
    PortMbus_1(5),
    PortMbus_2(6),
    PortReserved(30),
    PortCarrier(31);

    private byte value;

    private static Map<Byte, PortType> portList = new HashMap<>();
    static {
        for (PortType b : PortType.values()) {
            portList.put(b.value, b);
        }
    }

    private PortType(int v) {
        this.value = (byte) v;
    }

    public static PortType findPortByValue(byte v) {
        if (v < 1 || v > 31)
            return null;
        return portList.get(v);
    }

    /**
     * @return the value
     */
    public byte getValue() {
        return value;
    }
}
